﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Data.Common;
using System.Data;
using WPF_DbCenter.CommonMethod;
using CustomControl.DynaProgressBar;

namespace WPF_DbCenter.UI
{
    public partial class Main
    {
        PageSwitchProgressBar dp;

        /// <summary>
        /// Start Processing bar 
        /// </summary>
        private void StartProcessingBar()
        {
            if (Properties.Settings.Default.IsUseOldStyleProcessBar)
            {

                dp = PageSwitchProgressBar.X_BeginLoadingDialog();

                dp.SetColorStyle(PageSwitchProgressBar.ColorStyle.YellowStyle);
            }
            else
            {
                this.progressBar1.Visibility = Visibility.Visible;
                this.progressBar1.IsIndeterminate = true;
            }
        }

        /// <summary>
        /// Stop Processing bar shhowing
        /// </summary>
        private void StopProcessingBar()
        {
            if (Properties.Settings.Default.IsUseOldStyleProcessBar)
            {
                dp.X_EndLoadingDialog();
            }
            else
            {
                this.progressBar1.Visibility = Visibility.Hidden;
                this.progressBar1.IsIndeterminate = false;
            }
        }

        /// <summary>
        /// Get Current Selected TreeItem Value
        /// </summary>
        /// <returns></returns>
        private TreeItemArgs GetArgsFromSelectedItem()
        {
            TreeItemArgs result = null;

            TreeViewItem item = mainTreeView.SelectedItem as TreeViewItem;
            if (item != null)
            {
                result = item.Tag as TreeItemArgs;
            }
            return result;
        }

        /// <summary>
        /// Get the selected Item's parent itme value
        /// </summary>
        /// <returns></returns>
        private TreeItemArgs GetParentItemArgs()
        {
            TreeItemArgs result = null;

            TreeViewItem item = mainTreeView.SelectedItem as TreeViewItem;
            TreeViewItem parentItem = item.Parent as TreeViewItem;

            if (parentItem != null)
            {
                result = parentItem.Tag as TreeItemArgs;
            }
            return result;
        }

        /// <summary>
        /// Get Top nodes args
        /// </summary>
        /// <returns></returns>
        private TreeItemArgs GetTopNodeArgs()
        {
            TreeItemArgs result = null;

            TreeViewItem item = mainTreeView.SelectedItem as TreeViewItem;
            TreeViewItem parentItem = item.Parent as TreeViewItem;
            TreeViewItem topItem = parentItem.Parent as TreeViewItem;

            if (topItem != null)
            {
                result = topItem.Tag as TreeItemArgs;
            }
            return result;
        }

 
    }
}
